import { createRouter, createWebHistory } from 'vue-router'

//  导入首页面
import HomeView from '../views/HomeView.vue'
//  导入登录页
import LoginView from '../views/login/LoginView.vue'
//  导入主页
import HomePage from '@/views/HomePage.vue'
//  导入管理员和用户的页面
import AdminIndexView from '@/views/admin/AdminIndexView.vue'
import AdminListView from '@/views/admin/AdminListView.vue'
import UserListView from '@/views/admin/UserListView.vue'
//  导入轮播图
import AddBannerView from '@/views/banner/AddBannerView.vue'
import BannerIndexView from '@/views/banner/BannerIndexView.vue'
import BannerListView from '@/views/banner/BannerListView.vue'
//  导入宠物页
import PetIndexView from '@/views/pet/PetIndexView.vue'
import DogListView from '@/views/pet/DogListView.vue'
import CatListView from '@/views/pet/CatListView.vue'

// 菜单配置用于AsideCom.vue渲染菜单
export const menuConfig = [
  {
    path: '/admin',
    label: '账号管理',
    icon:'UserFilled',
    children: [
      { path: '/admin/adminList', label: '管理员列表' },
      { path: '/admin/userList', label: '用户列表' },
    ],
  },
  {
    path: '/banner',
    label: '轮播图管理',
    icon:'PictureFilled',
    children: [
      { path: '/banner/bannerList', label: '轮播图列表' },
      { path: '/banner/addBanner', label: '添加轮播图' },
    ],
  },
  {
    path: '/pet',
    label: '宠物管理',
    icon:'Flag',
    children: [
      { path: '/pet/dogList', label: '狗狗百科' },
      { path: '/pet/catList', label: '猫咪百科' },
    ],
  },
];

// 完整路由配置用于路径和组件的映射
const routes = [
  {
    path: '/',
    // name: 'home', name 属性移到 HomePage 子路由上
    component: HomeView,
    children: [
      {
        path: '',  // 默认子路由，匹配 `/` 时显示 HomePage
        component: HomePage,
        name: 'home',
      },
      {
        path: '/admin',
        component: AdminIndexView,
        children: [
          {
            path: 'adminList',
            component: AdminListView,
          },
          {
            path: 'userList',
            component: UserListView,
          },
        ],
      },
      {
        path: '/banner',
        component: BannerIndexView,
        children: [
          {
            path: 'bannerList',
            component: BannerListView,
          },
          {
            path: 'addBanner',
            component: AddBannerView,
          },
        ],
      },
      {
        path: '/pet',
        component: PetIndexView,
        children: [
          {
            path: 'dogList',
            component: DogListView,
          },
          {
            path: 'catList',
            component: CatListView,
          },
        ],
      },
      // {
      //   path: '/login',
      //   name: 'login',
      //   component: LoginView,
      // },
    ],
  },
  {
    path: '/login',
    name: 'login',
    component: LoginView,
  },
];

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes,
});

export default router;